<template>
  <section
    class="el-container"
    :class="{ 'is-vertical': isVertical }"
  >
    <slot />
  </section>
</template>

<script lang="ts" setup>
import { computed, VNode, Component, useSlots } from "vue";

interface Props{
  direction?:string
}

const props = defineProps<Props>();
const slots = useSlots();
const isVertical = computed(() => {
  if (slots.default) {
    console.log("slots", slots.default());
    return slots.default().some((vn:VNode) => {
      const tag = (vn.type as Component).name;
      return tag === "ElHeader" || tag === "ElFooter";
    });
  }

  return props.direction === "vertical";

});
</script>

<script lang="ts">
export default {
  name: "ElContainer",
};
</script>

<style lang="scss" scoped>
@import '../styles/mixins.scss';
@include b(container) {
  display: flex;
  flex-direction: row;
  flex: 1;
  flex-basis: auto;
  box-sizing: border-box;
  min-width: 0;
  @include when(vertical) {
    flex-direction: column;
  }
}

</style>
